from global_values import gg
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class my1(QWidget):
    def __init__(self):
        super().__init__()        
    def closeEvent(self,e):
        a.quit()

class my5(QWidget):
    def __init__(self,pos):
        super().__init__()        
        self.pos = pos
        icon_g = QIcon('arrow_m.cur')     
        self.setWindowFlags(Qt.WindowStaysOnTopHint|Qt.FramelessWindowHint|Qt.ToolTip)
        mouse_cursor_size2 = self.mouse_cursor_size2 = 32
        self.mouse_cursor_pixmap2 = icon_g.pixmap(icon_g.actualSize(QSize(mouse_cursor_size2, mouse_cursor_size2)))
        t2 = QTimer(self)
        t2.timeout.connect(self.ont)
        t2.start(10)
        self.hide()
        self.x = 0

    def paintEvent(self,e):                 
        p = QPainter(self) 
        ma = self.mouse_cursor_pixmap2.mask()                   
        self.setMask(ma)                             
        p.setRenderHint(QPainter.Antialiasing);        
        p.drawPixmap(0,0,self.mouse_cursor_size2,self.mouse_cursor_size2,self.mouse_cursor_pixmap2)
        print('update')
    
    def ont(self):
        if gg.status==0 or abs(gg.y-gg.pos[self.pos])<35:# not gg.showL[self.pos]:
            if not self.isHidden() :
                self.hide()
            return
        if self.x!=gg.x:    
            self.setGeometry(gg.x+3,gg.pos[self.pos],32,32)
            self.x = gg.x
        if self.isHidden():
            self.show()


import threading
from test import testa
t = threading.Thread(target=testa)
t.daemon = True
t.start()
a = QApplication([])  

w7 = my5(0)
w = my5(1)
# w5 = my5(480)
w6 = my5(2)
w2 = my1()
w2.show()
a.exec_()